package com.wpp.controller;


import com.wpp.common.lang.Result;
import com.wpp.entity.User;
import com.wpp.service.UserService;
import org.apache.shiro.authz.annotation.RequiresAuthentication;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author wpy
 * @since 2021-06-10
 */
@RestController
@RequestMapping("/user")
public class UserController {

    @Autowired
    UserService userService;


    @RequiresAuthentication
    @GetMapping("/index")
    public Result index() {
        User user = userService.getById(1L);
        //第一种方法
        Result resu = Result.resu(user);

        //第二种方法
        return Result.resu(200, "操作成功", user);
    }


    @PostMapping("/save")
    public Result save(@Validated @RequestBody User user) {
        //第二种方法
        return Result.resu(user);
    }
}
